import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import {list, deleteOne, batchDelete, getImportUrl,getExportUrl} from './SsPersonPosition.api';
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '姓名',
    align:"center",
    dataIndex: 'name'
   },
   {
    title: '管理部门',
    align:"center",
    dataIndex: 'departmentId_dictText'
   },
   /** 
   {
    title: '职位',
    align:"center",
    dataIndex: 'positionType',
    customRender:({text}) => {
       return  render.renderDict(text, 'positionType');
   },
   },*/
  {
    title: '管理类型',
    align:"center",
    dataIndex: 'managerType_dictText'
  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
	{
      label: "姓名",
      field: 'name',
      component: 'Input'
      //colProps: {span: 6},
 	},
  {
    label: '管理部门',
    field: 'departmentId',
    component: 'JSelectDept',
    componentProps:{
      checkable:false,
      multiple:false,
    },
    show:false,
  },
  /** 
	{
      label: "职位",
      field: 'positionType',
      component: 'JDictSelectTag',
      componentProps:{
        dictCode:"positionType",
        stringToNumber: true,
      }
      //colProps: {span: 6},
 	},*/
  {
    label: "管理类型",
    field: 'managerType',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"managerType",
      stringToNumber: true,
    }
    //colProps: {span: 6},
  },
];


/*async function listPosition(){
  let positions = await list({});
  let options = [];
  if(positions?.records){
    for(let i = 0;i<positions.records.length;i++){
      let op = {};
      op.label = positions.records[i].positionType_dictText;
      op.value = positions.records[i].id;
      options.push(op);
    }
  }
  return options;
}
const positions =await listPosition();*/

//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '姓名',
    field: 'personId',
    component: 'JSearchSelect',
    componentProps:{
       dict:"ss_person,name,id,status!=0"
    },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请选择人员!'},
          ];
     },
  },
  {
    label: '管理部门',
    field: 'departmentId',
     component: 'JSelectDept',
     componentProps:{
             checkable:false,
             multiple:false,
         },
     dynamicRules: ({model,schema}) => {
           return [
                  { required: true, message: '请选择部门!'},
           ];
      },
  },
  /** 
  {
    label: '职位',
    field: 'positionType',
    component: 'JDictSelectTag',
    componentProps:{
         dictCode:"positionType",
         stringToNumber: true
     },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请选择类型!'},
          ];
     },
  },*/
  {
    label: "管理类型",
    field: 'managerType',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: "managerType",
      stringToNumber: true,
    },
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];

// 高级查询数据
export const superQuerySchema = {
  personId: {title: '人员id',order: 0,view: 'sel_search', type: 'string'},
  departmentId: {title: '管理部门',order: 1,view: 'sel_depart', type: 'string'},
  positionType: {title: '职位',order: 2,view: 'number', type: 'number',pcode: ''}
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
